//
//  PPHttpRequsetData.m
//  dyseller
//
//  Created by 红喇叭 on 2017/8/10.
//  Copyright © 2017年 红喇叭. All rights reserved.
//

#import "PPHttpRequsetData.h"
#import "PPHttpManage.h"

static PPHttpRequsetData *requsetManage = nil;
@implementation PPHttpRequsetData

+(PPHttpRequsetData *)shareInstance{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if (!requsetManage) {
            requsetManage = [[self alloc]init];
        }
    });
    
    return requsetManage;
}

+(id)allocWithZone:(NSZone *)zone{
    @synchronized(self){
        if (!requsetManage) {
            requsetManage = [super allocWithZone:zone];
        }
    }
    return requsetManage;
}

-(id)init{
    @synchronized(self)
    {
        if (self = [super init])
        {
            [self initData];
        }
    }
    
    return self;
}

- (void)initData{
    
}

- (void)requestStyle:(Requset_Style)style URL:(NSString *)url parameter:(NSDictionary *)param successBlock:(YYCommCompleteBlock)success failBlock:(YYCommErrorBlock)failure{
    PPHttpRequest *request = [PPHttpRequest requestStyle:style URL:url parameter:param successBlock:success failBlock:failure];
    [[PPHttpManage shareInstance] requestData:request];
}


- (void)requestStyle:(Requset_Style)style
                 URL:(NSString *)url
            isactive:(BOOL)active
           parameter:(NSDictionary *)param
        successBlock:(YYCommCompleteBlock)success
           failBlock:(YYCommErrorBlock)failure{
    
    PPHttpRequest *request = [PPHttpRequest requestStyle:style URL:url parameter:param successBlock:success failBlock:failure active:active];
    [[PPHttpManage shareInstance] requestData:request];
    
}

- (void)uploadImages:(Requset_Style)style
                 URL:(NSString *)url
            isactive:(BOOL)active
           imageData:(NSArray *)imageArray
         imgfileName:(NSString *)filename
           parameter:(NSDictionary *)param
        successBlock:(YYCommCompleteBlock)success
           failBlock:(YYCommErrorBlock)failure{
    PPHttpRequest *request = [PPHttpRequest uploadImages:Request_POST URL:url isactive:active imageData:imageArray imgfileName:filename parameter:param successBlock:success failBlock:failure];
    [[PPHttpManage shareInstance] requestData:request];
    
}


@end
